# coding = UTF-8
# @Time : 2021/11/21 19:48
# @Author : PP_YY
# @File : readxls.py
# @Version : 0.0.1
# descrition: read .xls file
import xlrd


def readxls(_filepath,_sheetname):
    data = xlrd.open_workbook(_filepath)
    sheet = data.sheet_by_name(_sheetname)
    nrows = sheet.nrows # 得到行数
    ncols = sheet.ncols # 得到列数
    for i in range(nrows):
        iolist = sheet.row_values(rowx=i,start_colx=0,end_colx=None)
        # iolist = sheet.row(i) # 返回第i行的列表
        for j in range(ncols):
            print(iolist[j],end="|")
            # print(type(iolist[j]),end="|")
        print("")


if __name__ == "__main__":
    filepath = "/home/Codes/python/潘猪的爬虫小学习_P/豆瓣top250.xls"
    sheetname = "豆瓣top250"
    readxls(filepath,sheetname)
